package com.phoenix.jsef.framework;

import com.phoenix.jsef.common.SnowflakeIdWorker;
import com.phoenix.jsef.framework.annotations.IdType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.UUID;

/**
 * @version V1.0
 * @ClassName: IdGenerator
 * @Description:TODO(ID 生成器)
 * @author: 李启联
 * @date: 2019-11-26 11:01
 * @Copyright: Copyright (c), 2018-2019
 * 申明：本内容未经作者本人同意,禁止外泄以及用于其他的商业项目.
 */
public class IdGenerator {

    private static final Logger logger = LoggerFactory.getLogger(IdGenerator.class);

    private static final SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);

    public static Object generate(IdType idType){
        switch (idType){
            case NONE: return null;
            case AUTO: return null;
            case UUID: return UUID.randomUUID().toString().toUpperCase().replace("-", "");
            case ID_WORKER: return idWorker.nextId();
            case ID_WORKER_STR: return Long.toHexString(idWorker.nextId()).toUpperCase();
            default: return null;
        }
    }


}
